package com.dylan.database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class TestDerby {
	
	public static void main(String[] args) throws Exception, IllegalAccessException, ClassNotFoundException {
		String driver = "org.apache.derby.jdbc.EmbeddedDriver";
        String url = "jdbc:derby:";
        String facetDir = "./data/";
        Class.forName(driver).newInstance();
        Connection connection = DriverManager.getConnection(url + facetDir+ ";create=true");
        connection.setAutoCommit(true);
        Statement stmt = connection.createStatement();
        String creatSql="CREATE TABLE  testDB (" + "facetId INTEGER PRIMARY KEY," + " name VARCHAR(256))";
        stmt.executeUpdate(creatSql);
        int count = 0;
        count = stmt.executeUpdate("INSERT INTO testDB(facetId, name) " + "VALUES(1, '123')");
        System.out.println("count = " + count);
        count = stmt.executeUpdate("INSERT INTO testDB(facetId, name) " + "VALUES(2, '123')");
        System.out.println("count = " + count);
        count = stmt.executeUpdate("INSERT INTO testDB(facetId, name) " + "VALUES(3, '123')");
        System.out.println("count = " + count);
	}
	
}
